package com.lushu.helpers
{
	import com.lushu.events.ResourceEvent;
	import com.lushu.helpers.io.GenericIO;
	import com.lushu.info.ApplicationData;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class ConfigReader extends EventDispatcher
	{
		private var ioUtil_ : GenericIO;
		
		public function ConfigReader()
		{
			ioUtil_ = new GenericIO("./config/main.xml");
			ioUtil_.addEventListener(ResourceEvent.FILE_LOADED, getConfig);
			ioUtil_.read();
		
		}
		
		private function getConfig(e : ResourceEvent) : void
		{
			var xmlResource : XML = ioUtil_.getFileData();
			ApplicationData.BASE_LOCATION = xmlResource.baseLocation;
			ApplicationData.TILESET_DIRECTORY = xmlResource.tilesetDirectory;
			ApplicationData.VETEMENT_DIRECTORY = xmlResource.vetementDirectory;
			dispatchEvent(new Event("configRead"));
		}

	}
}